import 'package:flutter/cupertino.dart';
import 'package:sonora/models/sj_content_more_item_data.dart';

class SjBottomSheetView {
  // 显示自定义的 BottomSheet
  static void show({
    required BuildContext context,
    required List<SjContentMoreItemData> options,
    required void Function(BuildContext,SjContentMoreItemData) onOptionSelected,
  }) {
    showCupertinoModalPopup(
      context: context,
      builder: (BuildContext build) {
        return CupertinoActionSheet(
          actions: options.map((option) {
            return CupertinoActionSheetAction(
              child: Text(option.name ?? '', style: TextStyle(fontSize: 17, color: Color(0xff333333)),),
              onPressed: () {
                Navigator.of(context).pop(); // 关闭 BottomSheet
                onOptionSelected(context, option); // 调用回调函数并传递选中的选项
              },
            );
          }).toList(),
          cancelButton: CupertinoActionSheetAction(
            child: Text('Cancel', style: TextStyle(fontSize: 17, color: Color(0xff333333)),),
            isDestructiveAction: true, // Optional, makes the button red
            onPressed: () {
              Navigator.of(context).pop(); // 关闭 BottomSheet
            },
          ),
        );
      },
    );
  }
}
